package com.softeem.blog.dao;

import java.util.List;

import com.softeem.blog.entity.Img;
import com.softeem.blog.utils.DBUtils;

public class ImgDAO implements IBaseDAO<Img>{

	@Override
	public boolean insert(Img t) {
		String sql = "insert into img(path,bid) values(?,?)";
		return DBUtils.exeUpdate(sql, t.getPath(),t.getBid());
	}

	@Override
	public boolean deleteById(int id) {
		String sql = "delete from img where id=?";
		return DBUtils.exeUpdate(sql, id);
	}

	@Override
	public boolean update(Img t) {
		//TODO
		return false;
	}

	@Override
	public Img findById(int id) {
		String sql = "select * from img where id=?";
		return DBUtils.queryOne(Img.class, sql, id);
	}

	@Override
	public List<Img> findByPage(int pageSize, int pageNow) {
		String sql = "select * from img limit ?,?";
		return DBUtils.queryList(Img.class, sql, (pageNow-1)*pageSize,pageSize);
	}

	@Override
	public int getCount() {
		String sql = "select count(*) from img";
		return DBUtils.queryCount(sql);
	}

}
